﻿using System.Collections.Generic;
using MyCpuMonitor.Classes;
using MyCpuMonitor.Classes.WMI;


namespace MyCpuMonitor.Controls
{
    /// <summary>
    /// Interaction logic for ControlCpuInfo.xaml
    /// </summary>
    public partial class ControlCpuInfo 
    {
        public ControlCpuInfo()
        {
            InitializeComponent();

            ListBoxBasicInfo.ItemsSource = CreateBasicCpuInfo();
            ListBoxMoreInfo.ItemsSource = CreateMoreCpuInfo();
        }

        private static System.Collections.IEnumerable CreateBasicCpuInfo()
        {
            var c = new List<CpuInfoItem>();
            var p = new Processor();
            var cs = new ComputerSystem();

            c.Add(new CpuInfoItem {Name = "Name", Value = p.Name(0)});
            c.Add(new CpuInfoItem { Name = "Number Of Processors", Value = cs.NumberOfProcessors() });
            c.Add(new CpuInfoItem {Name = "Manufacturer", Value = p.Manufacturer(0)});
            c.Add(new CpuInfoItem {Name = "Family", Value = p.Family(0)});
            c.Add(new CpuInfoItem {Name = "Stepping", Value = p.Stepping(0)});
            c.Add(new CpuInfoItem {Name = "Processor Id", Value = p.ProcessorId(0)});
            c.Add(new CpuInfoItem {Name = "Max Clock Speed", Value = p.MaxClockSpeed(0) + "MHz"});
            c.Add(new CpuInfoItem {Name = "Status", Value = p.Status(0)});
            return c;
        }

        private static System.Collections.IEnumerable CreateMoreCpuInfo()
        {
            var c = new List<CpuInfoItem>();
            var p = new Processor();
            c.Add(new CpuInfoItem {Name = "Address Width", Value = p.AddressWidth(0)});
            c.Add(new CpuInfoItem {Name = "Architecture", Value = p.Architecture(0)});
            c.Add(new CpuInfoItem {Name = "Availability", Value = p.Availability(0)});
            c.Add(new CpuInfoItem {Name = "Caption", Value = p.Caption(0)});
            c.Add(new CpuInfoItem {Name = "Config Manager Error Code", Value = p.ConfigManagerErrorCode(0)});
            c.Add(new CpuInfoItem {Name = "Config Manager User Config", Value = p.ConfigManagerUserConfig(0)});
            c.Add(new CpuInfoItem {Name = "Cpu Status", Value = p.CpuStatus(0)});
            c.Add(new CpuInfoItem {Name = "Creation Clas sName", Value = p.CreationClassName(0)});
            c.Add(new CpuInfoItem {Name = "Current Clock Speed", Value = p.CurrentClockSpeed(0)});
            c.Add(new CpuInfoItem {Name = "Current Voltage", Value = p.CurrentVoltage(0)});
            c.Add(new CpuInfoItem {Name = "Data Width", Value = p.DataWidth(0)});
            c.Add(new CpuInfoItem {Name = "Description", Value = p.Description(0)});
            c.Add(new CpuInfoItem {Name = "Device ID", Value = p.DeviceId(0)});
            c.Add(new CpuInfoItem {Name = "Error Cleared", Value = p.ErrorCleared(0)});
            c.Add(new CpuInfoItem {Name = "Error Description", Value = p.ErrorDescription(0)});
            c.Add(new CpuInfoItem {Name = "Ext Clock", Value = p.ExtClock(0)});
            c.Add(new CpuInfoItem {Name = "Family", Value = p.Family(0)});
            c.Add(new CpuInfoItem {Name = "Install Date", Value = p.InstallDate(0)});
            c.Add(new CpuInfoItem {Name = "L2 Cache Size", Value = p.L2CacheSize(0)});
            c.Add(new CpuInfoItem {Name = "L2 Cache Speed", Value = p.L2CacheSpeed(0)});
            c.Add(new CpuInfoItem {Name = "L3 Cache Size", Value = p.L3CacheSize(0)});
            c.Add(new CpuInfoItem {Name = "L3 Cache Speed", Value = p.L3CacheSpeed(0)});
            c.Add(new CpuInfoItem {Name = "Last Error Code", Value = p.LastErrorCode(0)});
            c.Add(new CpuInfoItem {Name = "Level", Value = p.Level(0)});
            c.Add(new CpuInfoItem {Name = "Load Percentage", Value = p.LoadPercentage(0)});
            c.Add(new CpuInfoItem {Name = "Manufacturer", Value = p.Manufacturer(0)});
            c.Add(new CpuInfoItem {Name = "Max Clock Speed", Value = p.MaxClockSpeed(0)});
            c.Add(new CpuInfoItem {Name = "Name", Value = p.Name(0)});
            c.Add(new CpuInfoItem {Name = "Number Of Cores", Value = p.NumberOfCores(0)});
            c.Add(new CpuInfoItem {Name = "Number Of Logical Processors", Value = p.NumberOfLogicalProcessors(0)});
            c.Add(new CpuInfoItem {Name = "Other Family Description", Value = p.OtherFamilyDescription(0)});
            c.Add(new CpuInfoItem {Name = "PNP Device ID", Value = p.PnpDeviceId(0)});
            c.Add(new CpuInfoItem {Name = "Power Management Capabilities", Value = p.PowerManagementCapabilities(0)});
            c.Add(new CpuInfoItem {Name = "Power Management Supported", Value = p.PowerManagementSupported(0)});
            c.Add(new CpuInfoItem {Name = "Processor Id", Value = p.ProcessorId(0)});
            c.Add(new CpuInfoItem {Name = "Processor Type", Value = p.ProcessorType(0)});
            c.Add(new CpuInfoItem {Name = "Revision", Value = p.Revision(0)});
            c.Add(new CpuInfoItem {Name = "Role", Value = p.Role(0)});
            c.Add(new CpuInfoItem {Name = "Socket Designation", Value = p.SocketDesignation(0)});
            c.Add(new CpuInfoItem {Name = "Status", Value = p.Status(0)});
            c.Add(new CpuInfoItem {Name = "Status Info", Value = p.StatusInfo(0)});
            c.Add(new CpuInfoItem {Name = "Stepping", Value = p.Stepping(0)});
            c.Add(new CpuInfoItem {Name = "System Creation ClassName", Value = p.SystemCreationClassName(0)});
            c.Add(new CpuInfoItem {Name = "System Name", Value = p.SystemName(0)});
            c.Add(new CpuInfoItem {Name = "Unique Id", Value = p.UniqueId(0)});
            c.Add(new CpuInfoItem {Name = "Upgrade Method", Value = p.UpgradeMethod(0)});
            c.Add(new CpuInfoItem {Name = "Version", Value = p.Version(0)});
            c.Add(new CpuInfoItem {Name = "Voltage Caps", Value = p.VoltageCaps(0)});


            return c;
        }
    }
}

/*


*/